package oop.basicConcept;

/*
    它的功能有加,减,乘,除,累加,阶乘，求平方,求次方,判断一个数是否为素数
    并写测试类来测试这个方法
 */
public class Calculator {

    int plus(int a,int b){
        return a+b;
    }

    int minus(int a,int b){
        return a-b;
    }

    int multiply(int a,int b){
        return a*b;
    }

    int divide(int a,int b){
        return a/b;
    }

    int square(int a){
        return (int)Math.pow(a,2);
    }

    int power(int a,int index){
        return (int)Math.pow(a,index);
    }

    boolean isPrime(int a){
        boolean b = true;
        for (int i = 2; i < a/2; i++) {
            if(a % i == 0){
                b = false;
                break;
            }
        }
        return b;
    }

    public static void main(String[] args) {
        Calculator cal = new Calculator();
        System.out.println(cal.power(3, 4));
        System.out.println(cal.square(10));
        System.out.println(cal.isPrime(23));
    }
}
